# -*- coding: UTF-8 -*-
from django.db import models
from django.contrib.auth.models import User
import datetime

class FriendGroup(models.Model):
    '''好友组。包含默认组和自定义组，组都可以编辑和删除'''
    user = models.ForeignKey(User)
    name = models.CharField(max_length=128, default=u'')
    is_default = models.BooleanField(default=False)
    
    class Meta:
        db_table = 'friend_group'
        
    def __unicode__(self):
        return self.name
        
class Friendship(models.Model):
    user = models.ForeignKey(User, related_name='user_set')
    friend = models.ForeignKey(User, related_name='friend_set')
    create_date = models.DateTimeField(default=datetime.datetime.now())
    is_confirmed = models.BooleanField(default=False)
    confirm_date = models.DateTimeField(null=True)
    group = models.ForeignKey(FriendGroup)
    note = models.TextField(default=u'')
    
    class Meta:
        db_table = 'friendship'
